package com.hcss.core.common.logsmgt.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hcss.core.common.logsmgt.service.LoginLogService;
import com.hcss.core.mvc.BaseController;
import com.hcss.core.mvc.page.Pager;


/**
 * @ClassName: LoginLog 
 * @Description: TODO 登陆日志
 * @author lvfang
 * @date 2013-12-9 下午4:42:26 
 *
 */
@Controller
@RequestMapping("/logs")
public class LoginLogController extends BaseController {

	@Autowired
	private LoginLogService loginLogService;
	
	/**
	 * 跳转页面
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/index")
	public String index()throws Exception{
		return "/logs/loginList";
	}
	
	/**
	 * 返回所有登陆List json数据
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/loginList", method = RequestMethod.POST)
	@ResponseBody
	public Map<String,Object> getAllLoginLog(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Map<String,Object> parameterMap = request.getParameterMap();
		String userId = request.getParameter("userId");
		Pager page = loginLogService.getAllLoginLog(this.getPager(parameterMap), userId);
		return this.getCurrentPager(page);
	}

}
